﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Properties;
using System.Data;
using System.Data.SqlClient;

namespace IngressApp.DAC
{
    public class DACUpdate
    {
        DBInfo Info = new DBInfo();

        public bool updateRecord(Empleado obj, int idEmpleado)
        {
            SqlConnection con = new SqlConnection(Info.sqlSet());

            string query = "UPDATE Empleado SET Nombre='" + obj.Nombres
                + "',ApellidoPaterno='" + obj.ApellidoPaterno
                + "',ApellidoMaterno='" + obj.ApellidoMaterno + "',Estado='" + obj.Estado + "' WHERE IdEmpleado = " + idEmpleado;
            SqlCommand com = new SqlCommand(query, con);
            con.Open();

            if (com.ExecuteNonQuery() > 0)
                return true;
            else
                return false;

        }
        public bool updateRecord(EmpleadoHuella obj, int idEmpleado)
        {
            SqlConnection con = new SqlConnection(Info.sqlSet());
            SqlCommand cmd = new SqlCommand("SP_EmpleadoHuella_Update",con);
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@IdEmpleado", SqlDbType.Int).Value = idEmpleado;
            cmd.Parameters.Add("@IdTipoHuella", SqlDbType.Int).Value = obj.TipoHuella;
            cmd.Parameters.Add("@Huella", SqlDbType.VarChar).Value = obj.Huella;

            con.Open();

            if (cmd.ExecuteNonQuery() > 0)
                return true;
            else
                return false;

        }
        public bool updateRecord(Registro obj, int idRegistro)
        {
            SqlConnection con = new SqlConnection(Info.sqlSet());

            string query = "UPDATE Registro SET IdEmpleado='" + obj.IdEmpleado
                + "',Estado='" + obj.Estado
                + "',Fecha='" + obj.Fecha + "' WHERE IdRegistro = " + idRegistro;
            SqlCommand com = new SqlCommand(query, con);
            con.Open();

            if (com.ExecuteNonQuery() > 0)
                return true;
            else
                return false;

        }
        public bool updateRecord(TipoHuella obj, int idTipoHuella)
        {
            SqlConnection con = new SqlConnection(Info.sqlSet());

            string query = "UPDATE TipoHuella SET Clave='" + obj.Clave
                + "', Descripcion='" + obj.Descripcion
                + "' WHERE IdTipoHuella = " + idTipoHuella;
            SqlCommand com = new SqlCommand(query, con);
            con.Open();

            if (com.ExecuteNonQuery() > 0)
                return true;
            else
                return false;

        }
    }
}
